<?php

	class bRest {
		private static $nMajor =1;
		private static $nMinor =0;
		private static $sRevision ="0000";
		
		const POST_ARRAY 	="@(->post => art-k-tec systems llc)";
		const GET_ARRAY 	="@(-->get => art-k-tec systems llc)";
		
		private $ConstructReturn;
		
		public function __construct() {
			
			$sServerMethod =strtoupper($_SERVER['REQUEST_METHOD']);
		
			if($sServerMethod =='GET' || $sServerMethod =='PUT' || $sServerMethod =='DELETE' || $sServerMethod =='POST') {
				
				$sPath =isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : 'default';
				$sPath =($sPath[0] =='/' ? substr($sPath, 1) : $sPath);

				$aPath =explode('/', $sPath);
				$sMethod =array_shift($aPath);
				
				if($sServerMethod =='POST') {
					$aPath[self::POST_ARRAY] =$_POST;

				}
				
				if($sServerMethod =='GET') {
					$aPath[self::GET_ARRAY] =$_GET;

				}
				
				$this->ConstructReturn =call_user_func_array(array($this, $sMethod.'_'.$sServerMethod), $aPath);
			}
		}
		
		public static function version() { return self::$nMajor.'.'.self::$nMinor.'.'.self::$sRevision; }
		
		public function Result() {
			
			return $this->ConstructReturn;
		}
		
		public function __call($sMethod, $aParameter) {
			echo "The method [{$sMethod}] was not found:";
		}
		
		public function Default_DELETE() {

			echo "nothing.";
			// throw exception or something?
		}
			
		public function Default_GET() {
			
			// throw exception or something?
			echo "nothing.";
		}
		
		public function Default_POST() {
			
			// throw exception or something?
			echo "nothing.";
		}
		
		public function Default_PUT() {
			
			// throw exception or something?
			echo "nothing.";
		}
	}

?>